home *** CD-ROM | disk | FTP | other *** search
/ Power CD / Power CD ATARI-Rechner Lieben.iso / DEMOS / HM2_DEMO / BSP / SIMPLE.CPX / SIMPLE.M < prev   
Encoding:
Text File  |  1992-10-08  |  2.3 KB  |  118 lines

  1. MODULE SimpleCPX;
  2. (*
  3.  * einfachstes CPX-Demo
  4.  *
  5.  * angelehnt an das Beispiel S. 721 ff. aus
  6.  * Jankowski/Rabich/Reschke: ATARI Profibuch ST-STE-TT, Sybex
  7.  *
  8.  * Aus diesem Beispiel sollte ersichtlich sein, daß die C-Routine cpx_init()
  9.  * in Modula-2 durch den gesamten Initialisierungsteil des Programms gebildet
  10.  * wird. Die Rückgabe erfolgt durch die Routine CPX.Return().
  11.  *
  12.  * Ein komplexeres Beispiel findet sich mit SampleCPX in SAMPLE.M
  13.  *)
  14.  
  15. (*
  16.  * (c) 10/1992 A. Alich, C. Sprenger
  17.  *)
  18. IMPORT AES, CPX, evnt, objc;
  19. FROM SYSTEM IMPORT ADR, LONG;
  20.  
  21. CONST
  22.     nObs = 2;
  23.  
  24. TYPE
  25.     tObj = RECORD
  26.         next, head, tail: SHORTINT;
  27.         type: SHORTCARD;
  28.         flags, state: BITSET;
  29.         spec: LONG;
  30.         rect: AES.tRect;
  31.     END;
  32.     tTree = ARRAY [0..nObs] OF tObj;
  33.     tpTree = POINTER TO tTree;
  34.  
  35. CONST
  36.     cRsc = tTree{
  37.         {
  38.             -1, 1, 2,
  39.             objc.Box, {}, {},
  40.             LONG(1101H),
  41.             {0, 0, 32, 11}
  42.         },
  43.         {
  44.             2, -1, -1,
  45.             objc.String, {}, {},
  46.             LONG(0),
  47.             {6, 3, 8, 1}
  48.         },
  49.         {
  50.             0, -1, -1,
  51.             objc.Button, {objc.LastObj, objc.Exit, objc.Default, objc.Selectable},
  52.             {},
  53.             LONG(0),
  54.             {12, 9, 6, 1}
  55.         }
  56.     };
  57.  
  58. VAR
  59.     pTree: tpTree;
  60.  
  61. (*$E+*)(*$K+*)
  62. PROCEDURE cpx_call (VAR work: AES.tRect): SHORTINT;
  63.  
  64.     VAR
  65.         msg: evnt.tMsg;
  66.  
  67.     BEGIN
  68.         WITH pTree^[0].rect DO
  69.             x := work.x;
  70.             y := work.y;
  71.         END;
  72.         objc.draw (pTree, 0, 8, work);
  73.         VOID (CPX.pXCPB^.Xform_do (pTree, 0, msg));
  74.         (*
  75.          * Da bei jedem Aufruf des CPX dieses initialisiert wird, und dieses
  76.          * via CPX.Return() beendet wird, muß die Terminierungskette vorher
  77.          * "per Hand" aktiviert werden:
  78.          *)
  79.         CPX.Terminate;
  80.         RETURN 0
  81.         (*
  82.          * Hier ist die CPX-Ausführung beendet.
  83.          *)
  84.     END cpx_call;
  85. (*$E=*)(*$K=*)
  86.  
  87. VAR
  88.     title: ARRAY [0..21] OF CHAR;
  89.     ok: ARRAY [0..3] OF CHAR;
  90.     i: SHORTINT;
  91.  
  92. (*
  93.  * Der Module-Body dient als cpx_init()-Funktion.
  94.  *)
  95. BEGIN
  96.     WITH CPX.pXCPB^ DO
  97.         IF booting # 0 THEN
  98.             CPX.Return (CPX.tpCpxInfo(1))
  99.         END;
  100.         pTree := ADR (cRsc);
  101.         IF SkipRshFix = 0 THEN
  102.             FOR i := 0 TO nObs DO
  103.                 rsh_obfix (pTree, i)
  104.             END;
  105.         END;
  106.         title := 'Hänisch-Modula-2 CPX'; pTree^[1].spec := LONG(ADR (title));
  107.         ok := 'OK'; pTree^[2].spec := LONG(ADR (ok));
  108.         CPX.CpxInfo.cpx_call := cpx_call;
  109.         (*
  110.          * CPX.Return() bekommt den Rückgabewert von cpx_init() auf den Weg.
  111.          *)
  112.         CPX.Return (ADR (CPX.CpxInfo))
  113.         (*
  114.          * Hierher kommt das Programm NIE!
  115.          *)
  116.     END;
  117. END SimpleCPX.
  118.             
  119.     
  120.